class_name HoldSpellWaterBullet
extends BaseHoldItem


@onready var bullet_born_point: Marker2D = $BulletBornPoint
@export var bullet_resource_name: String = "particle_water_bullet"


func use():
	var player = holder as Player
	var config = item_data.item_config as ItemAttackSpellConfig
	
	var inst = (ResourceManager.get_resource(bullet_resource_name) as PackedScene).instantiate()
	player.level.bullets_parent.add_child(inst)
	inst.global_position = bullet_born_point.global_position
	inst.attack = config.attack + player.player_data.get_attack()
	inst.critical_rate = config.critical_rate
	inst.critical_bonus = config.critical_bonus
	inst.knockback = config.knockback
	if config.attack_cam_shake:
		inst.hit_cam_shake_strength = config.attack_cam_shake_intensity
		inst.hit_cam_shake_duration = config.attack_cam_shake_duration
	inst.sender = player
	inst.global_rotation = player.gun_hand.global_rotation
	inst.dir = Vector2.from_angle(player.gun_hand.global_rotation)
	inst.set_is_enemy(false)
	
